﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynORM.Interfaces
{
    //its implementation usually has identity-based equality semantics
    //it can be processed with Identity map and Unit of work in the layer above
    public interface IRowDescriptor : IORMObjectDescriptor
    {
        string TableName { get; } //uniquely identify RowDescriptor. Do not change during it's lifetime
        IPrimaryKeyDescriptor PrimaryKeyDescriptor { get; }

        //fields 
        IEnumerable<IFieldDescriptor> FieldDescriptors { get; }

        void AddField(IFieldDescriptor fieldDescriptor);
        void RemoveField(IFieldDescriptor fieldDescriptor);

        //relations
        IEnumerable<IRelationDescriptor> RelationDescriptors { get; }
        IEnumerable<IForeignKeyDescriptor> ForeignKeyDescriptors { get; }

        void AddRelation(IRelationDescriptor relationDescriptor);
        void RemoveRelation(IRelationDescriptor relationDescriptor);

        bool ContainsField(string fieldName);
        IFieldDescriptor GetField(string fieldName);

        //Auxiliary methoeds
        void InforceFieldNameUniqness();
        void InforceRelationNameUniqness();
    }
}
